@{
    Layout = null;
}

<!DOCTYPE html>
<html>
<head>
    <style>
        html, body {
            margin: 0;
            padding: 0;
        }

        iframe {
            position: absolute;
            width: 100%;
            height: 100%;
            border: none;
        }
    </style>
</head>
<body>
    @Html.Raw(Netnr.SharedApp.QuoteTo.Html("loading"))

    <!--UI-->
    <iframe src="/lib/dk/dk.html" scrolling="no"></iframe>

    <!-- 扩展脚本 -->
    <script data-dk="true">
        if (window.dk) {
            $('.dkn-menu').hide();

            dk.api = location.origin;

            //接口地址
            dk.apiPath["QueryTableConfig"] = "/DK/QueryTableConfig";
            dk.apiPath["SaveTableConfig"] = "/DK/SaveTableConfig";

            //设定为后台数据库连接信息
            dk.dc.backConn = true;
            //默认数据库
            $('#seti').val('@ViewData["tdb"]');
            $('#btnQueryTable').addClass('d-none');

            //载入文件注入
            $.getScript('/lib/dk/dk_ext.js');
        }
    </script>

    <script>
        var dke = {
            //多个扩展之间等待时间，单位：毫秒
            defer: 1000,
            iframe: document.getElementsByTagName('iframe')[0],

            //初始化
            init: function () {
                dke.uisrc = dke.iframe.src;

                //加载扩展
                dke.iframe.onload = function () {
                    dke.runScript();

                    //隐藏加载
                    setTimeout(function () {
                        document.getElementById("LoadingMask").style.display = "none";
                    }, 500);
                }
            },

            /**
             * 执行脚本
             */
            runScript: function (si) {
                var scripts = document.getElementsByTagName('script'), si = si || 0;
                var ei = scripts[si++];
                //是扩展脚本
                if (ei && ei.getAttribute('data-dk') == "true") {
                    //解析模版变量
                    var eii = ei.innerHTML.replace(/{{.*?}}/g, function (jv) {
                        return eval('(' + jv.substring(2, jv.length - 2) + ')');
                    });
                    eii = encodeURIComponent(eii);
                    if (eii.length > 4000) {
                        console.warn("由于 URL 长度有限制，请分批注入拓展，注入脚本内容编码后长度限制 4000 ，已被截断，当前长度：" + eii.length);
                    } else {
                        console.log("注入脚本编码后长度为：" + eii.length + "（MAX：4000）");
                    }
                    //赋值hash
                    dke.iframe.src = dke.uisrc + '#' + eii.substring(0,4000);
                }
                //等待
                if (si < scripts.length) {
                    setTimeout(function () {
                        dke.runScript(si)
                    }, dke.defer);
                }
            }
        }

        dke.init();
    </script>
</body>
</html>